Repository navigation
Conversation
A shared-token connect saved the new token and cleared the bootstrap token before the gateway accepted the connection. A rejection now restores the previous record, asks the settings callback to follow that record, and reconnects a gateway that was already live. If the rollback cannot be saved, the new gateway stays active. The handshake budget is 15 seconds. Set OPENCLAW_SHARED_TOKEN_HANDSHAKE_TIMEOUT_MS to change it. An attempt that is still connecting when the budget ends stays committed, because the gateway has not rejected it yet. Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
|
🦞👀 ClawSweeper review completeClawSweeper finished reviewing this revision. |
|
Codex review: needs real behavior proof before merge. What this changesRestore saved gateway configuration, connection settings, and a previously live connection when shared-token replacement fails. Example: Replace the token for wss://test1, whose saved record contains old-shared and bootstrap-token, with rejected-token.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial Merge readiness⛔ Blocked before merge - 2 items remain This PR addresses credential loss still present on current main, and the latest revision resolves the previous settings-serialization finding. Reviewed head: Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe local MCP shared-token command enters GatewayConnectionManager, which coordinates gateway persistence, operator authentication, and callbacks into the existing settings and tunnel service. flowchart TD
A[Local MCP command] --> B[GatewayConnectionManager]
B --> C[GatewayRegistry]
B --> D[Operator connection]
B --> E[GatewayDirectConnectService]
E --> F[Saved connection settings]
E --> G[Runtime SSH tunnel]
Technical reviewBest possible solution: Keep recovery in the existing manager and settings service, with an owner-approved authentication observation contract and demonstrated preservation of existing saved configuration. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the bootstrap-only failure path: replacement is persisted before asynchronous authentication, and failure retains it; no builds, tests, or runtime reproduction were run during this read-only review. Is this the best way to solve the issue? The existing connection manager and settings service are appropriate owners, and the latest revision repairs snapshot serialization without adding a parallel transaction service. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6a92b23e9b19. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
Root-cause clusterRelationship: Members:
These related items are listed for context. Any action on an item requires its own checks. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed December 2, 2026, 1:48 AM ET / 06:48 UTC (Revision 3). |
A rejected shared token still restores the previous gateway. A failure to write the new device token means the gateway already accepted the token. Disconnecting that attempt abandoned the replacement pairing. Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
A first shared-token attempt has no previous gateway. Rejection removed the new registry record but left settings on that rejected address. The shared-token handler now puts the saved URL and tunnel back. Rollback failures tell the user to open Connection settings and reconnect. Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
|
@clawsweeper re-review Head e272c33 restores the settings captured before a first shared-token attempt when that attempt is rejected and there is no previous gateway. Rollback failures now say to open Connection settings and reconnect a valid gateway. A device-token save failure stays on the new gateway. The 15 second handshake cutoff, and a live Companion rejection against a populated profile, are still open. |
|
🦞👀 Re-review progress:
|
A second shared-token call could snapshot the first attempt's temporary settings while that attempt waited outside the lifecycle lease. Capture and the empty-registry restore now run only after the lease and the transition lock are held. If the settings callback fails on a first gateway, the pre-attempt snapshot is restored before the lease is released. A restore that cannot be saved leaves the candidate active. Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
|
@clawsweeper re-review The settings snapshot is now taken after the shared-token call holds the lifecycle lease. A second call cannot capture the first attempt's temporary settings. Empty-registry restore also runs before that lease is released, including when the settings callback fails. The 15 second cutoff is still a maintainer decision. This head still has no Companion window, populated v2026.11.3 profile, or SSH listener proof. |
|
🦞👀 Re-review progress:
|
Related: #2439
Closes #2439
What Problem This Solves
Connecting Companion with a shared token saves that token and clears the bootstrap token before the gateway accepts the connection. If the gateway then rejects the token, the previous gateway, its bootstrap token, and its SSH tunnel stay cleared. The failed gateway is left active. A first attempt, with no previous gateway, also left settings pointing at the rejected address.
User Impact
User impact: a rejected shared token puts Companion back on the previous gateway, including the bootstrap token, saved connection settings, and a connection that was already live. If that was the first gateway, settings return to what they were before the attempt. A second attempt waits until that restore has finished, so it cannot save the rejected address as the snapshot it would restore. If that restore cannot be saved, the new gateway stays active and the failure says to open Connection settings and reconnect. Saving a new device token after the gateway has accepted the shared token does not undo that gateway.
Why This Change Was Made
The shared token was stored, and the settings callback ran, before the operator connection was admitted. A rejection now writes the previous record back, runs that same callback with the restored record, drops the rejected operator client, and reconnects a gateway that was already connected. When there is no previous record, the shared-token handler restores the settings snapshot taken after the attempt holds the lifecycle lease.
A second shared-token call cannot take that snapshot until the first call has restored settings and released the lease. If the settings callback fails before a first gateway is left active, that same restore runs before the lease is released.
The gateway can reject the token after the connect call returns. The attempt waits up to 15 seconds for that rejection. Set OPENCLAW_SHARED_TOKEN_HANDSHAKE_TIMEOUT_MS to change the budget. An attempt that is still connecting when the budget ends stays on the new record, because the gateway has not rejected it. Whether that cutoff should instead wait until authentication finishes is a maintainer decision. A failure to write the new device token is also left in place. Cancellation after the save stays on the new record.
This is a new branch from current main. Closed pull #1509 is not reopened.
Evidence
On source
8ca63225inC:\Users\sebta\wt-wn-2439(.NET SDK 10.0.404, Windows AMD64):./build.ps1exited 0. Cli, Shared, WinNodeCli, WinUI, and SetupEngine built.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restorepassed 7394, skipped 0, failed 0.dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restorepassed 1858, skipped 1 (Migration_CopiesAcrossConfiguredDistinctVolume), failed 0.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restorepassed 6279, skipped 28, failed 0.e272c33bpassed, 31 checks, 12 skipped, including Revocation recovery. That run is not this head.A rejection delivered after connect returns, for a record that still had
old-sharedandbootstrap-token, came back as connection failed, gateway not committed, the saved tokenold-shared, and the bootstrap token restored. Two overlapping first-gateway calls recordeda-start,a-commit,a-restore, thenb-start. The second call did not start until the first restore finished. A device-identity save failure stayed on the new shared token.Required proof pools
none: this change rolls back the connection manager and the saved connection settings after a rejected shared token. It does not change the signed installer, ARM64 runtime, MXC containment, WSL gateway setup, or a WinUI window layout.Validation
Head
8ca63225690e85448e00c88f8d2b68f20170f0ff. Host: Windows AMD64, .NET SDK 10.0.404../build.ps1exit 0e272c33b: pass, 31 checks, 12 skipped. Not this head.Real behavior proof